package com.pxmeta.common.config;

import com.baidubce.BceClientConfiguration;
import com.baidubce.auth.DefaultBceCredentials;
import com.baidubce.services.vcr.VcrClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
 * Doc: https://cloud.baidu.com/doc/VCR/s/Zjwvyb1uu
 */
@Configuration
public class BaiduConfig {

    @Value("${baidu.accessKeyId}")
    private String accessKeyId;

    @Value("${baidu.secretAccessKey}")
    private String secretAccessKey;

    private final String endPointUrl = "http://vcr.bj.baidubce.com";


    public VcrClient getVcrClient() {
        String ACCESS_KEY_ID = accessKeyId;
        String SECRET_ACCESS_KEY = secretAccessKey;
        // 初始化一个VcrClient
        BceClientConfiguration config = new BceClientConfiguration();
        config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY));
        // 如果有需要，可以用https协议
        config.setEndpoint(endPointUrl);
        return new VcrClient(config);
    }

}
